<?php
namespace soa\express\counterman;
use soa\client;

/**
 * Class Counterman
 * getByMobile          通过手机号返回tbl_counterman_phone表所有关联记录
 * getByMobiles         通过多个手机号返回tbl_counterman_phone表所有关联记录
 * getByCode            通过工号返回tbl_counterman_phone表所有关联记录
 * getByCodes           通过多个工号返回tbl_counterman_phone表所有关联记录
 * getByBranchCode      通过网点编号返回所有下属快递员信息(第三个参数控制是否包含子网点，目前只有申通维护了上下级关系，默认是false不包含)
 */

class Counterman extends client
{
    /**
     * 服务地址
     * @var string
     */
    public $service_url = 'http://express.core.kuaidihelp.com/';

    /**
     * 服务名称
     * @var string
     */
    protected $service_name = 'kuaidihelp_express';

    /**
     * 通过手机号返回tbl_counterman_phone表所有关联记录
     * @param $mobile
     * @return array|mixed|string
     */
    public function getByMobile($mobile)
    {
        if($mobile)
        {
            $url = 'v1/counterman/Info/getByMobile';
            $param['mobile'] = $mobile;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 通过多个手机号返回tbl_counterman_phone表所有关联记录
     * @param $mobiles
     * 接收数组参数或者字符串参数
     * @return array|mixed|string
     */
    public function getByMobiles($mobiles)
    {
        if($mobiles)
        {
            $url = 'v1/counterman/Info/getByMobiles';
            $param['mobiles'] = $mobiles;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 通过工号返回tbl_counterman_phone表所有关联记录
     * @param $code
     * @param string $brand
     * @return array|mixed|string
     */
    public function getByCode($code,$brand = '')
    {
        if($code)
        {
            $url = 'v1/counterman/Info/getByCode';
            $param['counterman_code'] = $code;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 通过多个工号返回tbl_counterman_phone表所有关联记录
     * 接收数组参数或者字符串参数
     * @param $codes
     * @param string $brand
     * @return array|mixed|string
     */
    public function getByCodes($codes,$brand = '')
    {
        if($codes)
        {
            $url = 'v1/counterman/Info/getByCodes';
            $param['counterman_codes'] = $codes;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 通过网点编号返回所有下属快递员信息(第三个参数控制是否包含子网点，默认是false不包含)
     * @param $branchCode
     * @param string $brand
     * @param bool $subBranch
     * @return array|bool|null
     */
    public function getByBranchCode($branchCode,$brand = '',$subBranch = false)
    {
        if($branchCode)
        {
            if($subBranch)
                $url = 'v1/counterman/Info/getSubCountermanByBranchCode';
            else
                $url = 'v1/counterman/Info/getCountermanByBranchCode';
            $param['branch_code'] = $branchCode;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }
}